import axios, { Axios, AxiosResponse } from "axios";
import apiConfig from "../apis/Apis";
const instance =axios.create({
    baseURL: 'http://42.192.139.163:7001',
    timeout: 10*1000
});
instance.interceptors.response.use(
    response => response,
)
export const request = (name:string, params:any):Promise<AxiosResponse> => {
    const api = (apiConfig as any)[name];
    const {url, method} = api;
    if (method === 'get'){
        return get(url, params)
    }else {
        return post(url, params)
    }

}
export const get = (url:string, param:any):Promise<AxiosResponse> => {
    return instance.get(url, {
        params:param
    })
}

export const post = (url:string, param:any):Promise<AxiosResponse> =>{
    return instance.post(url, param)
}